package com.guzhen.wallpager;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import com.fun.funlivewallpaper.R;

import java.util.Random;

public class TodayStepHandle {
    private final int screenHeight;
    private Context ctx;
    private long todayStep;
    private final int dp145;
    private final Paint paint;
    private final int screenWidth;

    public TodayStepHandle(Context context0) {
        this.ctx = context0;
        this.screenWidth = ScreenUtils.getScreenWidth();
        this.dp145 = ScreenHelper.getDimensionPixelSize(R.dimen.gz_dp_145);
        this.screenHeight = ScreenUtils.getScreenHeight();
        Paint paint0 = new Paint();
        this.paint = paint0;
        paint0.setColor(Color.parseColor("#FFFFFFFF"));
        paint0.setTextSize(((float)ScreenHelper.getDimensionPixelSize(R.dimen.gz_dp_14)));
        paint0.setFakeBoldText(true);
        paint0.setAntiAlias(true);
//        StepCounterService.lIlI1liIIL.lIlI1liIIL().iLiLiIL1L((StepServiceData stepServiceData0) -> this.setTodayStepAsync(stepServiceData0));
        getTodayStep();
    }

    private void getTodayStep() {
        this.todayStep = new Random().nextInt(1000);
    }

    long lastTime = 0;
    public void drawTextKianKa(Canvas canvas0) {
        if (System.currentTimeMillis() - lastTime > 10_000) {
            setTodayStep();
            lastTime = System.currentTimeMillis();
        }
        StringBuilder stringBuilder0;
//        StepCounterService.lIlI1liIIL.lIlI1liIIL().iLiLiIL1L((StepServiceData stepServiceData0) -> this.getTodayStepAsync(stepServiceData0));
        stringBuilder0 = new StringBuilder();
        stringBuilder0.append("今日运动已消耗：");

        try {
            stringBuilder0.append(todayStep);
            stringBuilder0.append("千卡");
            String s = stringBuilder0.toString();
            float f = this.paint.measureText(s);
            canvas0.drawText(s, (((float)this.screenWidth) - f) / 2.0f, ((float)(this.screenHeight - this.dp145)), this.paint);
            return;
        }
        catch(Exception unused_ex) {
        }

    }

//    private void setTodayStepAsync(StepServiceData stepServiceData0) {
//        IL1L1iL1.L1lLIll1lI1(() -> this.setTodayStep(stepServiceData0));
//    }
//
//    private void getTodayStepAsync(StepServiceData stepServiceData0) {
//        IL1L1iL1.L1lLIll1lI1(() -> this.getTodayStep(stepServiceData0));
//    }

    private void setTodayStep() {
        this.todayStep = new Random().nextInt(1000);
    }
}

